
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/scrip.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>View Producer Admin</title>
</head>
<body>
<div class="master-wrapper-content">
	<jsp:include page="heading.jsp"></jsp:include>
	<%
		System.out.println(session.getAttribute("roleId"));
		if(session.getAttribute("roleId") == null || String.valueOf(session.getAttribute("roleId")).equalsIgnoreCase("2")) {
			%>
				<h3 style="color: red">Không đủ quyền để truy cập</h3>
			<%
		}
		else {
	%>
	<jsp:include page="CategoryAdmin.jsp"></jsp:include>
	<%
		List<Producer> producers = dataManager.getAllProducer();
	%>
	<div class="container-right">	
			<div class="ml-banner">
				<div class="ml-title">Quản lý nhà sản xuất</div>
			</div>		
			<table class="table-view">
				<tr class="title">
					<th>Name</th>
					<th>Edit</th>
					<th>Delete</th>
				</tr>
				<%
					int count = 0;
					for (Producer producer : producers) {
						String str = "";
						++count;
						if (count % 2 == 0)
							str = "even";
						else
							str = "odd";
				%>
	
				<tr class="<%=str%>">
					<td><%=producer.getProducerName()%></td>
					<td><a
						href="<%="/ECommerce/EditProducerAdmin.jsp?producerId="
							+ producer.getProducerId()%>">Sửa</a>
					</td>
					<td><a
						href="<%="/ECommerce/DeleteProducer?producerId="
							+ producer.getProducerId()%>">Xóa</a>
					</td>
				</tr>
				<%
					}
				%>
			</table>
	
			<p>Thêm nhà sản xuất</p>
			<form action="AddProducer" method="post">
				<table border="1">
					<tr>
						<td>Tên nhà sản xuất</td>
						<td><input type="text" name="producerName" />
						</td>
						<td><input type="submit" value="Add Producer" />
						</td>
					</tr>
				</table>
			</form>
		</div>
	<div class="clear"></div>
	<%
		}
	%>
	<jsp:include page="footer.jsp"></jsp:include>
</div>
</body>
</html>